package it.xiuxian.homepage.presenter

import com.lzy.okgo.OkGo
import it.xiuxian.homepage.bean.MonGongXianBean
import it.xiuxian.homepage.fragment.GongXianFragment
import it.xiuxian.lib.base.BaseBean
import it.xiuxian.lib.base.BaseFragment
import it.xiuxian.lib.base.BasePresenter
import it.xiuxian.lib.base.ILoadBind
import it.xiuxian.lib.http.CallBackOption
import it.xiuxian.lib.http.HttpConfig

class GongXianFragmentPresenter:BasePresenter<GongXianFragment>() {
    fun getMonGongxian(){
        OkGo.post<BaseBean<MonGongXianBean>>(HttpConfig.BASE_URL+"/apppaihangbang/yuebang")
            .execute(object : CallBackOption<BaseBean<MonGongXianBean>>() {}.loadBind(mView as GongXianFragment).execute(
                object : ILoadBind<BaseBean<MonGongXianBean>> {
                    override fun excute(bean: BaseBean<MonGongXianBean>) {
                        if(bean.code==0){
                            (mView as GongXianFragment).setGongXian(bean.data)
                        }
                    }
                }
            ))
    }
    fun getZongGongxian(){
        OkGo.post<BaseBean<MonGongXianBean>>(HttpConfig.BASE_URL+"/apppaihangbang/zongbang")
            .execute(object : CallBackOption<BaseBean<MonGongXianBean>>() {}.loadBind(mView as GongXianFragment).execute(
                object : ILoadBind<BaseBean<MonGongXianBean>> {
                    override fun excute(bean: BaseBean<MonGongXianBean>) {
                        if(bean.code==0){
                            (mView as GongXianFragment).setZong(bean.data)
                        }
                    }
                }
            ))
    }
}